/**********************************************************************
 *
 * $RCSfile: ConnectionSynchronization.java,v $  $Revision: 1.2 $  $Date: 2009/09/28 02:02:46 $
 *
 * $Log: ConnectionSynchronization.java,v $
 * Revision 1.2  2009/09/28 02:02:46  @author simplefan
 * *** empty log message ***
 *
 * Revision 1.1  2009/09/07 02:23:14  @author simplefan
 * *** empty log message ***
 *
 *
 *
 *********************************************************************/
/*
 * Copyright 2008 gxlu, Inc. All rights reserved.
 * File name : ConnectionSynchronization.java
 * Created on : Sep 5, 2009 5:14:56 PM
 * Creator : lethe
 */
package com.simplefan.meta.eda;

import org.apache.log4j.Logger;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;

/**
 * <pre>
 * Description : TODO
 * @author simplefan
 * </pre>
 */
public class ConnectionSynchronization extends TransactionSynchronizationAdapter {
  private static Logger logger = Logger.getLogger(ConnectionSynchronization.class);

  private Event event = null;

  public ConnectionSynchronization(Event event){
    this.event = event;
  }

  @Override
  public void afterCompletion(int status) {
    int eventStatus = event.getEventType().getOnEventTransactionStatus().intValue();
    if(status == eventStatus) {
      EventPublishTool.publishImmediate(event);
    }
    else {
      logger.info("EVENT no publish, current status:" + status + "|  event:" + event);
    }
  }
}
